//
//  SCNBaseTableView.swift
//  ShoucainuSwift
//
//  Created by 王家旭 on 2017/4/25.
//  Copyright © 2017年 Riluee. All rights reserved.
//

import UIKit
import MJRefresh

class SCNBaseTableView: UITableView {
    
    typealias pullUpAction = () -> Void
    typealias pullDownAction = () -> Void


    
    override init(frame: CGRect, style: UITableViewStyle) {
        super.init(frame: frame, style: style)
        
        self.backgroundColor = SCNConstants.tableViewBackgroundColor
        
        self.tableFooterView = UIView()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    func pullUp(_ action: @escaping pullUpAction) {
        
        self.mj_header = MJRefreshNormalHeader(refreshingBlock: {
            // TODO : Load more data
            action()
        })
        
    }
    
    func pullDown(_ action: @escaping pullDownAction) {
       
        self.mj_footer = MJRefreshAutoNormalFooter(refreshingBlock: {
            // TODO : Load new data
            action()
        })
    }
    

}
